program binary2;
Uses sysutils;

var i:string;
var n,l,v,j:longint;

function int_power(x,p:integer):integer;
var j:integer;
begin
	int_power := 1;
	for j:=1 to p do
		int_power:=int_power*x;
end;

begin
	Writeln ('The time is : ',TimeToStr(Time));

	writeln('Input base');
	readln(n);
	writeln('Input number');
	readln(i);

	for j:=0 to 10000000 do begin
	
	v:=0;
	for l:=length(i) downto 1 do begin
		v:= v + ( integer(i[l])-integer('0') )* int_power(n,length(i)-l);
	end;
	
	end;
	writeln(v);
	Writeln ('The time is : ',TimeToStr(Time));

end.